from rest_framework import viewsets, generics
from rest_framework.decorators import action

from .models import Log
from .serializers import LogSerializer
from .filters import LogFilter


class LogViewSet(viewsets.GenericViewSet, generics.ListAPIView):
    queryset = Log.objects.all()
    serializer_class = LogSerializer
    filterset_class = LogFilter
    ordering_fields = ('id',)

    def list(self, request, *args, **kwargs):
        return super().list(request, *args, **kwargs)

    @action(methods=['get'], detail=False, url_path='modules')
    def modules(self, request, *args, **kwargs):
        return super().list(request, *args, **kwargs)
